<?php
# deliver.php
# 消息推送专用
# 推送的消息来源格式是极光推送的数据格式
# 参数由POST传输过来
# 个推需要用到的
require_once(dirname(dirname(__FILE__))."/application/config/common_config.php");
define('MY_API_HOST' 	 ,$config['api_host']);
if(!$_POST){
	echo 'err';exit;
}
$pushData['sendno'] 			=$_POST['sendno'];
$pushData['app_key'] 			=$_POST['app_key'];
$pushData['receiver_type'] 		=$_POST['receiver_type'];		# 接收者类型 2,指定的 tag;3,指定的 alias;4,广播：对 app_key 下的所有用户推送消息;
$pushData['receiver_value'] 	=$_POST['receiver_value'];		# 发送范围值，与 receiver_type 相对应。2,App 调用 SDK API 设置的 tag （标签）。支持多达 10 个，使用 "," 间隔;3,App 调用 SDK API 设置的 alias （别名）。支持多达 1000 个，使用 "," 间隔;
$pushData['verification_code'] 	=$_POST['verification_code'];
$pushData['msg_type'] 			=$_POST['msg_type'];			# 发送消息的类型：１,通知;２,自定义消息（只有 Android 支持）
$pushData['msg_content'] 		=$_POST['msg_content'];			# 发送消息的内容。与 msg_type 相对应的值。
$pushData['msg_content']=str_replace('\"','"',$pushData['msg_content']);
$pushData['msg_content']=str_replace('/\/\u','\u',$pushData['msg_content']);
if(isset($_POST['n_builder_id'])){
	$pushData['n_builder_id'] 	=$_POST['n_builder_id'];
}
$pushData['send_description'] 	=$_POST['send_description'];
$pushData['platform'] 			=$_POST['platform'];			# 目标用户终端手机的平台类型，如： android, ios, winphone 多个请使用逗号分隔。
$pushData['time_to_live'] 		=$_POST['time_to_live'];

# 开始个推的推送
header("Content-Type: text/html; charset=utf-8");
define('SELFPATH' 	 ,dirname(__FILE__).'/');
require_once(SELFPATH.'IGt.Push.php');
define('APPKEY' 	 ,'TbBz4BQpdd7Die1gII0UO');
define('APPID' 		 ,'8XbBkXjT3e7DrdgQYgNYd3');
define('MASTERSECRET','p63fB2QBql8SVbkvwi6tp1');
define('HOST' 		 ,'http://sdk.open.api.igexin.com/apiex.htm');

/*
$fh=fopen(SELFPATH.'pushlog.log','a');
fwrite($fh,"\r\n".date("Y-m-d H:i:s")." post res\r\n");
fwrite($fh,"pushData=".json_encode($pushData));
fwrite($fh,"\r\n==========================================\r\n");
fclose($fh);
*/

switch ($pushData['receiver_type']) {
	case 2:# jpush的tag形式，在个推里是推送到个人
		$url=MY_API_HOST.'user/member/getUserCID?jpushtoken='.$pushData['receiver_value'];
		$uid_cid_arr=get_curl($url);
		$uid_cid_arr=json_decode($uid_cid_arr,true);
		if(!$uid_cid_arr){
			# 错误
			#$fh=fopen(SELFPATH.'pushlog.log','a');
			#fwrite($fh,"\r\n".date("Y-m-d H:i:s")." post res\r\n");
			#fwrite($fh,"uid_cid_arr ".$pushData['receiver_type']);
			#fwrite($fh,"\r\n==========================================\r\n");
			#fclose($fh);
		}else{
			$cid_arr=array();
			$uid2os=array();
			foreach($uid_cid_arr as $i){
				$cid_arr[]=$i['cid'];
				$uid=$i['uid'];
				$uid2os[$uid]=$i['os'];
			}
			$myMessContent=pushData2xgData($pushData['msg_content'],$pushData['msg_type']);	# 把数据格式化成信鸽的
			$myMessContent['receiver_uid']=$uid;
			$gtContent=json_encode($myMessContent);

			$isIOS_tmp=$_POST['platform'];
			$isIOS_tmp=explode(',',$isIOS_tmp);
			$isIOS=false;
			foreach($isIOS_tmp as $iooo){
				if($iooo=='ios' || $iooo=='all'){
					$isIOS=true;
				}
			}
			if($uid2os[$myMessContent['receiver_uid']]==2){
				$isIOS=true;
			}

			if($isIOS){
				$tmp_msg_content=json_decode($pushData['msg_content'],true);
				$tmp_n_extras=$tmp_msg_content['n_extras'];
				$payload=array();
				$payload['receiver_value']=$pushData['receiver_value'];
				$payload['tp']=$tmp_n_extras['tp'];
				$payload['messageid']=$pushData['sendno'];
				if($tmp_n_extras['tp']==20){
					$payload['pmid']=$tmp_n_extras['m'];
				}
				if(isset($tmp_n_extras['type'])){
					$payload['type']=$tmp_n_extras['type'];
				}
				if(isset($tmp_n_extras['title'])){
					$payload['title']=$tmp_n_extras['title'];
				}
				if(isset($tmp_n_extras['mtype'])){
					$payload['mtype']=$tmp_n_extras['mtype'];
				}
				if(isset($tmp_n_extras['cmid'])){
					$payload['cmid']=$tmp_n_extras['cmid'];
				}
				if(isset($tmp_n_extras['t'])){
					$payload['t']=$tmp_n_extras['t'];
				}
				if(isset($tmp_n_extras['b'])){
					$payload['b']=$tmp_n_extras['b'];
				}
				if(isset($tmp_n_extras['url'])){
					$payload['url']=$tmp_n_extras['url'];
				}
				if(isset($tmp_n_extras['num'])){
					$payload['count']=$tmp_n_extras['num'];
				}
				if(isset($tmp_n_extras['cont'])){
					$payload['cont']=$tmp_n_extras['cont'];
				}
				if(isset($tmp_n_extras['product_id'])){
					$payload['pi']=(int)$tmp_n_extras['product_id'];
					$payload['si']=(int)$tmp_n_extras['shop_id'];
					$payload['product_id']=(int)$tmp_n_extras['product_id'];
					$payload['shop_id']=(int)$tmp_n_extras['shop_id'];
				}
				if(isset($tmp_n_extras['act_id'])){
					$payload['ai']=(int)$tmp_n_extras['act_id'];
					$payload['act_id']=(int)$tmp_n_extras['act_id'];
				}
				if(isset($tmp_n_extras['timesale'])){
					$payload['ts']=(int)$tmp_n_extras['timesale'];
				}
				$pushInfo=array(
			    	'message'=>(string)$myMessContent['content'],
			    	'payload'=>json_encode($payload),
			    );
			}else{
				$pushInfo=array();
			}
			
			$template=IGtTransmissionTemplateDemo(APPID,APPKEY,$gtContent,2,$isIOS,$pushInfo);
			$pushRes=pushMessageToList(HOST,APPID,APPKEY,MASTERSECRET,$cid_arr,$template);
			/*
			$fh=fopen(SELFPATH.'pushlog.log','a');
			fwrite($fh,"\r\n".date("Y-m-d H:i:s")." post res\r\n");
			fwrite($fh,"pushData=".json_encode($pushRes));
			fwrite($fh,"\r\n==========================================\r\n");
			fclose($fh);
			*/
		}
		break;
	case 3:# jpush的alias形式，在个推里是推送到个人
		$url=MY_API_HOST.'user/member/getUserCID?jpushtoken='.$pushData['receiver_value'];
		$uid_cid_arr=get_curl($url);
		$uid_cid_arr=json_decode($uid_cid_arr,true);
		if(!$uid_cid_arr){
			# 错误
			#$fh=fopen(SELFPATH.'pushlog.log','a');
			#fwrite($fh,"\r\n".date("Y-m-d H:i:s")." post res\r\n");
			#fwrite($fh,"uid_cid_arr ".$pushData['receiver_type']);
			#fwrite($fh,"\r\n==========================================\r\n");
			#fclose($fh);
		}else{
			$cid_arr=array();
			$uid2os=array();
			foreach($uid_cid_arr as $i){
				$cid_arr[]=$i['cid'];
				$uid=$i['uid'];
				$uid2os[$uid]=$i['os'];
			}
			$myMessContent=pushData2xgData($pushData['msg_content'],$pushData['msg_type']);	# 把数据格式化成信鸽的
			$myMessContent['receiver_uid']=$uid;
			$gtContent=json_encode($myMessContent);

			$isIOS_tmp=$_POST['platform'];
			$isIOS_tmp=explode(',',$isIOS_tmp);
			$isIOS=false;
			foreach($isIOS_tmp as $iooo){
				if($iooo=='ios' || $iooo=='all'){
					$isIOS=true;
				}
			}
			if($uid2os[$myMessContent['receiver_uid']]==2){
				$isIOS=true;
			}

			if($isIOS){
				$tmp_msg_content=json_decode($pushData['msg_content'],true);
				$tmp_n_extras=$tmp_msg_content['n_extras'];
				$payload=array();
				$payload['receiver_value']=$pushData['receiver_value'];
				$payload['tp']=$tmp_n_extras['tp'];
				$payload['messageid']=$pushData['sendno'];
				if($tmp_n_extras['tp']==20){
					$payload['pmid']=$tmp_n_extras['m'];
				}
				if(isset($tmp_n_extras['type'])){
					$payload['type']=$tmp_n_extras['type'];
				}
				if(isset($tmp_n_extras['title'])){
					$payload['title']=$tmp_n_extras['title'];
				}
				if(isset($tmp_n_extras['mtype'])){
					$payload['mtype']=$tmp_n_extras['mtype'];
				}
				if(isset($tmp_n_extras['cmid'])){
					$payload['cmid']=$tmp_n_extras['cmid'];
				}
				if(isset($tmp_n_extras['t'])){
					$payload['t']=$tmp_n_extras['t'];
					if(!isset($payload['title'])){
						$payload['title']=$tmp_n_extras['t'];
					}
				}
				if(isset($tmp_n_extras['b'])){
					$payload['b']=$tmp_n_extras['b'];
				}
				if(isset($tmp_n_extras['url'])){
					$payload['url']=$tmp_n_extras['url'];
				}
				if(isset($tmp_n_extras['num'])){
					$payload['count']=$tmp_n_extras['num'];
				}
				if(isset($tmp_n_extras['cont'])){
					$payload['cont']=$tmp_n_extras['cont'];
				}
				if(isset($tmp_n_extras['product_id'])){
					$payload['pi']=(int)$tmp_n_extras['product_id'];
					$payload['si']=(int)$tmp_n_extras['shop_id'];
					$payload['product_id']=(int)$tmp_n_extras['product_id'];
					$payload['shop_id']=(int)$tmp_n_extras['shop_id'];
				}
				if(isset($tmp_n_extras['act_id'])){
					$payload['ai']=(int)$tmp_n_extras['act_id'];
					$payload['act_id']=(int)$tmp_n_extras['act_id'];
				}
				if(isset($tmp_n_extras['timesale'])){
					$payload['ts']=(int)$tmp_n_extras['timesale'];
				}
				$pushInfo=array(
			    	'message'=>(string)$myMessContent['content'],
			    	'payload'=>json_encode($payload),
			    );
			}else{
				$pushInfo=array();
			}

			$template=IGtTransmissionTemplateDemo(APPID,APPKEY,$gtContent,2,$isIOS,$pushInfo);
			$pushRes=pushMessageToList(HOST,APPID,APPKEY,MASTERSECRET,$cid_arr,$template);
			/*
			$fh=fopen(SELFPATH.'pushlog.log','a');
			fwrite($fh,"\r\n".date("Y-m-d H:i:s")." post res\r\n");
			fwrite($fh,"pushData=".json_encode($pushRes));
			fwrite($fh,"\r\n==========================================\r\n");
			fclose($fh);
			*/
		}
		break;
	case 4:# jpush的APP全网广播形式，在个推里是推送到全网或者指定的tag
		$phoneType=array();
		$province=array();
		$tag_arr=array();
		if( isset($_POST['tags']) && strlen($_POST['tags'])>0 ){
			$tags=trim($_POST['tags'],'|');
			$tag_arr=explode('|',$tags);
		}
		$myMessContent=pushData2xgData($pushData['msg_content'],$pushData['msg_type']);	# 把数据格式化成信鸽的
		$gtContent=json_encode($myMessContent);
		
		$isIOS_tmp=$_POST['platform'];
		$isIOS_tmp=explode(',',$isIOS_tmp);
		$isIOS=false;
		foreach($isIOS_tmp as $iooo){
			if($iooo=='ios' || $iooo=='all'){
				$isIOS=true;
			}
		}

		if($isIOS){
			$tmp_msg_content=json_decode($pushData['msg_content'],true);
			$tmp_n_extras=$tmp_msg_content['n_extras'];
			$payload=array();
			$payload['receiver_value']=$pushData['receiver_value'];
			$payload['tp']=$tmp_n_extras['tp'];
			$payload['messageid']=$pushData['sendno'];
			if($tmp_n_extras['tp']==20){
				$payload['pmid']=$tmp_n_extras['m'];
			}
			if(isset($tmp_n_extras['type'])){
				$payload['type']=$tmp_n_extras['type'];
			}
			if(isset($tmp_n_extras['title'])){
				$payload['title']=$tmp_n_extras['title'];
			}
			if(isset($tmp_n_extras['mtype'])){
				$payload['mtype']=$tmp_n_extras['mtype'];
			}
			if(isset($tmp_n_extras['cmid'])){
				$payload['cmid']=$tmp_n_extras['cmid'];
			}
			if(isset($tmp_n_extras['t'])){
				$payload['t']=$tmp_n_extras['t'];
			}
			if(isset($tmp_n_extras['b'])){
				$payload['b']=$tmp_n_extras['b'];
			}
			if(isset($tmp_n_extras['url'])){
				$payload['url']=$tmp_n_extras['url'];
			}
			if(isset($tmp_n_extras['num'])){
				$payload['count']=$tmp_n_extras['num'];
			}
			if(isset($tmp_n_extras['cont'])){
				$payload['cont']=$tmp_n_extras['cont'];
			}
			if(isset($tmp_n_extras['product_id'])){
				$payload['pi']=(int)$tmp_n_extras['product_id'];
				$payload['si']=(int)$tmp_n_extras['shop_id'];
				$payload['product_id']=(int)$tmp_n_extras['product_id'];
				$payload['shop_id']=(int)$tmp_n_extras['shop_id'];
			}
			if(isset($tmp_n_extras['act_id'])){
				$payload['ai']=(int)$tmp_n_extras['act_id'];
				$payload['act_id']=(int)$tmp_n_extras['act_id'];
			}
			if(isset($tmp_n_extras['timesale'])){
				$payload['ts']=(int)$tmp_n_extras['timesale'];
			}
			$pushInfo=array(
		    	'message'=>$myMessContent['content'],
		    	'payload'=>json_encode($payload),
		    );
		}else{
			$pushInfo=array();
		}
		$template=IGtTransmissionTemplateDemo(APPID,APPKEY,$gtContent,2,$isIOS,$pushInfo);
		$pushRes=pushMessageToApp(HOST,APPID,APPKEY,MASTERSECRET,$template,$phoneType,$province,$tag_arr);
		/*
		$fh=fopen(SELFPATH.'pushlog.log','a');
		fwrite($fh,"\r\n".date("Y-m-d H:i:s")." post res\r\n");
		fwrite($fh,"pushData=".json_encode($pushRes));
		fwrite($fh,"\r\n==========================================\r\n");
		fclose($fh);
		*/
		#pushMessageToApp($getui_api_host,$gettuiAPPID,$getuiAPPKEY,$getuiMASTERSECRET,$template,$phoneType=array(),$province=array(),$tag_arr=array(),$taskName='全网推送')
		break;
	default:
		# code...
		break;
}

############################################## 个推相关方法 ##############################################


//
//服务端推送接口，支持三个接口推送
//1.PushMessageToSingle接口：支持对单个用户进行推送
//2.PushMessageToList接口：支持对多个用户进行推送，建议为50个用户
//3.pushMessageToApp接口：对单个应用下的所有用户进行推送，可根据省份，标签，机型过滤推送
//

#单推接口案例，推送给单一一个人
# 这里使用透传
function pushMessageToSingle($getui_api_host,$gettuiAPPID,$getuiAPPKEY,$getuiMASTERSECRET,$cid,$template){
    $igt = new IGeTui($getui_api_host,$getuiAPPKEY,$getuiMASTERSECRET);

    //个推信息体
	$message = new IGtSingleMessage();

	$message->set_isOffline(true);//是否离线
	$message->set_offlineExpireTime(3600*12*1000);//离线时间
	$message->set_data($template);//设置推送消息类型
	#$message->set_PushNetWorkType(0);//设置是否根据WIFI推送消息，1为wifi推送，0为不限制推送
	//接收方
	$target = new IGtTarget();
	$target->set_appId($appid);
	$target->set_clientId($cid);
	$rep = $igt->pushMessageToSingle($message,$target);
	return $rep;
}


//多推接口案例
function pushMessageToList($getui_api_host,$gettuiAPPID,$getuiAPPKEY,$getuiMASTERSECRET,$cid_arr,$template){
	putenv("needDetails=true");
	$igt = new IGeTui($getui_api_host,$getuiAPPKEY,$getuiMASTERSECRET);

	//个推信息体
	$message = new IGtListMessage();

	$message->set_isOffline(true);//是否离线
	$message->set_offlineExpireTime(3600*12*1000);//离线时间
	$message->set_data($template);//设置推送消息类型
	//$message->set_PushNetWorkType(0);	//设置是否根据WIFI推送消息，1为wifi推送，0为不限制推送
	$contentId = $igt->getContentId($message);
	//$contentId = $igt->getContentId($message,"toList任务别名功能");	//根据TaskId设置组名，支持下划线，中文，英文，数字

	//接收方1
	foreach($cid_arr as $cid){
		$target1 = new IGtTarget();
		$target1->set_appId($gettuiAPPID);
		$target1->set_clientId($cid);
		$targetList[] = $target1;
	}	
	$rep = $igt->pushMessageToList($contentId, $targetList);
	return $rep;
}

//群推接口案例
function pushMessageToApp($getui_api_host,$gettuiAPPID,$getuiAPPKEY,$getuiMASTERSECRET,$template,$phoneType=array(),$province=array(),$tag_arr=array(),$taskName='全网推送'){
	$igt = new IGeTui($getui_api_host,$getuiAPPKEY,$getuiMASTERSECRET);
	
	//个推信息体
	//基于应用消息体
	$message = new IGtAppMessage();
	$message->set_isOffline(true);
	$message->set_offlineExpireTime(3600*12*1000);//离线时间单位为毫秒，例，两个小时离线为3600*1000*2
	$message->set_data($template);
	//$message->set_PushNetWorkType(0);	//设置是否根据WIFI推送消息，1为wifi推送，0为不限制推送

 
	$message->set_appIdList(array($gettuiAPPID));
	if($phoneType){
		$message->set_phoneTypeList($phoneType);
	}
	if($province){
		$message->set_provinceList($province);
	}
	if($tag_arr){
		$message->set_tagList($tag_arr);
	}
	$rep = $igt->pushMessageToApp($message,$taskName);//根据TaskId设置组名，支持下划线，中文，英文，数字
	return $rep;
}


# 透传
function IGtTransmissionTemplateDemo($getuiAPPID,$getuiAPPKEY,$content,$run=2,$isIOS=false,$pushInfo=array()){
    $template =  new IGtTransmissionTemplate();
    $template->set_appId($getuiAPPID);			# 应用appid
    $template->set_appkey($getuiAPPKEY);		# 应用appkey
    $template->set_transmissionType($run); 		# 透传消息类型,收到消息是否立即启动应用，1为立即启动，2则广播等待客户端自启动
    $template->set_transmissionContent($content);# 透传内容，不支持转义字符
    if($isIOS){
    	$actionLocKey=( isset($pushInfo['actionLocKey']) ? $pushInfo['actionLocKey'] : NULL );
    	$badge 		 =( isset($pushInfo['badge']) ? $pushInfo['badge'] : NULL );
    	$badge=NULL;
    	$tmp=json_decode($content,true);
    	if($tmp['content']=='12' || $pushInfo['message']=='12' ){
    		$tmp['content']='您的贴子有新回复';
    		$pushInfo['message']='您的贴子有新回复';
    		$pushInfo['payload']=json_decode($pushInfo['payload'],true);
    		$pushInfo['payload']['tp']=12;
    		$pushInfo['payload']=json_encode($pushInfo['payload']);
    	}
    	$message 	 =( isset($pushInfo['message']) ? $pushInfo['message'] : $tmp['content'] );
    	$sound 	     =( isset($pushInfo['sound']) ? $pushInfo['sound'] : 'com.gexin.ios.silence' );
    	#$tmp['messageid']=sendno;
    	$payload 	 =( isset($pushInfo['payload']) ? $pushInfo['payload'] : json_encode(array("messageid"=>$tmp['messageid'])) );
    	$locKey 	 =( isset($pushInfo['locKey']) ? $pushInfo['locKey'] : NULL );
    	$locArgs 	 =( isset($pushInfo['locArgs']) ? $pushInfo['locArgs'] : NULL );
    	$launchImage =( isset($pushInfo['launchImage']) ? $pushInfo['launchImage'] : 'Default.png' );

		if(!$message){
			$message='您有新消息';
		}

	    # iOS推送需要设置的pushInfo字段
		$template ->set_pushInfo($actionLocKey,$badge,$message,$sound,$payload,$locKey,$locArgs,$launchImage);
    }	
    return $template;
}
############################################## 个推相关方法 ##############################################

# 设备类型转换
function jpushPlatform2xgDeviceType($platform){
	#$platform jpush的目标用户终端手机的平台类型，如： android, ios, winphone 多个请使用逗号分隔。
	$deviceType=0;# 默认不限,消息推送的适配平台：0：不限；1：浏览器；2：pc； 3：Android；4：ios； 5：windows phone
	switch ($platform) {
		case 'android':$deviceType=3;break;
		case 'ios':$deviceType=4;break;
		case 'winphone':$deviceType=5;break;
		default:$deviceType=0;break;
	}
	return $deviceType;
}

/**
 * pushData2xgData
 * 把极光推送的消息格式转换为信鸽推送的格式
 */
function pushData2xgData($pushData,$msg_type){
	if(!is_array($pushData)){
		$pushData=json_decode($pushData,true);
	}
	$myMessContent=array();
	if($msg_type==1){
		# 通知的格式
		$myMessContent['title']='考拉之家';
		$myMessContent['content']=(string)$pushData['n_content'];
		$custom=array();
		foreach($pushData['n_extras'] as $key => $val){
			if($key=='cont'){
				$val=urldecode($val);
			}
			$custom[$key]=(string)$val;
		}
		$myMessContent['custom']=$custom;
	}else{
		# 自定义消息的格式
		$myMessContent['title']='考拉之家';
		$myMessContent['content']=(string)$pushData['message'];
		$custom=array();
		foreach($pushData['extras'] as $key => $val){
			$custom[$key]=(string)$val;
		}
		$myMessContent['custom']=$custom;
	}
	return $myMessContent;
}


/**
 * post curl
 * 主要是把提交到这里的信息提交到极光推送
 */
function post_curl($url,$postfield_arr,$ua="MyLinuxCURL"){
    if(!$url || !$postfield_arr){
        return false;
    }
    $postfield_temp=array();
    foreach($postfield_arr as $key => $value){
        $postfield_temp[]=$key.'='.$value;
    }
    $postfield=join("&",$postfield_temp);
    unset($postfield_arr);
    unset($postfield_temp);

    $ch  = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postfield);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,500);
    curl_setopt($ch, CURLOPT_TIMEOUT,500);
    curl_setopt($ch, CURLOPT_USERAGENT,$ua);
    $curl_return = curl_exec($ch);
    if(curl_errno($ch)){
        # curl出错
        return false;
    }
    curl_close($ch);
    unset($ch);
    return $curl_return;
}

function get_curl($url,$ua="MyLinuxCURL"){
    $ch  = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,500);
    curl_setopt($ch, CURLOPT_TIMEOUT,500);
    curl_setopt($ch, CURLOPT_USERAGENT,$ua);      
    $curl_return = curl_exec($ch);
    if(curl_errno($ch)){
        //curl出错
        return false;
    } 
    curl_close($ch);
    unset($ch);
    return $curl_return;
}
?>